#include <stdio.h>
#include <unistd.h>
#include <signal.h>

void hand(int s)
{
	printf("信号处理函数:%d\n",s);
}

void handler(int s,siginfo_t* sigInfo,void* arg)
{
	printf("高级的信号处理函数:%d\n",s);
	printf("信号是%d发送过来的！\n",sigInfo->si_pid);
	printf("发送过来的数据:%d\n",sigInfo->si_int);
}

int main()
{
	struct sigaction act = {0};
	struct sigaction oldAct = {0};

	act.sa_handler = hand;
	act.sa_sigaction = handler;
	act.sa_flags = SA_SIGINFO;


	int r = sigaction(2,&act,&oldAct);
	while(1)
	{
		printf("%d正在运行!\n",getpid());
		sleep(1);
	}

	return 0;
}
